package reflect;

import org.junit.Test;

import java.lang.reflect.Array;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : ArrayTest
 * @Author : 54061
 * @Date: 2022/2/28 14:00
 */
public class ArrayTest {
    @Test
    public void textArray(){
        //通过Array创建一个Strig类型的数组是咧,长度为5
        Object o = Array.newInstance(String.class,5);
        //为数组中某个索引所对应的元素赋值
        Array.set(o,0,"张三");
        Array.set(o,2,"王五");
        //获取数组中某个索引所对应的元素值
        System.out.println(Array.get(o,0));
        System.out.println(Array.get(o,1));
        System.out.println(Array.get(o,2));
        System.out.println(Array.get(o,3));
        System.out.println(Array.get(o,4));
        System.out.println(Array.get(o,5));
    }
}
